package com.hgy.carsb.entity;


import lombok.Data;

import java.math.BigDecimal;

@Data
public class ProfitTrendDetail {
    private String thisYear;
    private String lastYear;
    private String subMonth;
    private String monthRate;

    public ProfitTrendDetail(String thisMonth, String lastMonth, String thisYear, String lastYear){
        this.thisYear = thisYear;
        this.lastYear = lastYear;
        this.subMonth = new BigDecimal(thisMonth).subtract(new BigDecimal(lastMonth)).toString();
        if (lastMonth.equals("0")){
            this.monthRate = "0";
        }else {
            this.monthRate = new BigDecimal(this.subMonth).multiply(new BigDecimal(100)).divide(new BigDecimal(lastMonth), 2, BigDecimal.ROUND_HALF_UP).toString();
        }
    }
}
